import { GUIComponent } from "../../../../com/mui/controls/GUIComponent";
import { Language } from "../../../../extend/language/Language";
import { TimeButton } from "../common/button/TimeButton";
import { GButton } from "../../../../com/mui/controls/GButton";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { DataEvent } from "../../events/DataEvent";
import { EventName } from "../../mvc/EventName";
import { Alert } from "../../../../com/mui/controls/Alert";
type int = number;
//class WareHouseBottomPart
    
    export  class WareHouseBottomPart extends GUIComponent
    {
        constructor()
        {
            super();
            this.width = 254;
            this.height = 30;
            return;
        }

        protected /* override */ createChildren(): void
        {
            var loc1=this.createBtn("hebing", Language.getString(42510), 0);
            this.createBtn("zhengli", Language.getString(42511), 1);
            this.createBtn("quchu", Language.getString(42512), 2);
            this._mergeBtn = loc1 as TimeButton;
            this._mergeBtn.toolTipData = Language.getString(42513);
            return;
        }

        /* internal  */createBtn(arg1: string, arg2: string, arg3: int): GButton
        {
            var loc1=null;
            if (arg1 != "quchu") 
            {
                if (arg1 != "zhengli") 
                {
                    loc1 = new TimeButton(10, false);
                }
                else 
                {
                    loc1 = new TimeButton(10);
                }
            }
            else 
            {
                loc1 = new GButton();
            }
            loc1.name = arg1;
            loc1.label = arg2;
            loc1.width = 47;
            loc1.height = 22;
            loc1.x = 102 + arg3 * 48;
            loc1.y = 12;
            loc1.styleName = "Button";
            loc1.addEventListener(flash.events.MouseEvent.CLICK, this.btnClickHandler);
            this.addChild(loc1);
            return loc1;
        }

        /* internal  */btnClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            var loc1=(arg1.target as GButton).name;
            switch (loc1) 
            {
                case "zhengli":
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.WareHouse_Tity));
                    break;
                }
                case "quchu":
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.WareHouse_TakeOut));
                    break;
                }
                case "hebing":
                {
                    Alert.show(Language.getString(42514), null, Alert.OK | Alert.CANCEL, null, this.onConfirmMerge);
                    break;
                }
            }
            return;
        }

        /* internal  */onConfirmMerge(arg1: int): void
        {
            if (arg1 == Alert.OK) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.WareHouse_Merge));
                this._mergeBtn.trigger();
            }
            return;
        }

        /* internal */ /* var */_mergeBtn: TimeButton;
    }
